package com.myzl.coal.client.channel.init;

import cn.hutool.extra.spring.SpringUtil;
import com.myzl.coal.client.BaseHandler;
import com.myzl.coal.client.channel.init.base.UdpChannelInitializer;
import com.myzl.coal.client.decoder.LengthFieldMultiplyDecoder;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.nio.NioDatagramChannel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


/**
 * @ClassName ClientChannelInitializer
 * @Author wzb
 * @Date 2023/1/18 16:08
 * @Description
 */
@Data
@AllArgsConstructor
@Component
@Slf4j
public class LidarChannelInitializer extends UdpChannelInitializer {

    @Override
    protected void initChannel(NioDatagramChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        pipeline.addLast(new LengthFieldMultiplyDecoder(10240, 6, 2, 0, 0));
//        p.addLast(new ByteArrayDecoder());
//        p.addLast(new ByteArrayEncoder());
        pipeline.addLast(SpringUtil.getBean(BaseHandler.class));
//        p.addLast(new DatagramPacketEncoder(new ByteArrayEncoder()));
    }

}
